import Vue from 'vue'
import Vuex from 'vuex'
// 可以把store数据本地化，存到local Storage中
import createPersistedState from "vuex-persistedstate"

//挂载Vuex
Vue.use(Vuex)

//创建VueX对象
const store = new Vuex.Store({
  state: {
    //存放的键值对就是所要管理的状态
    token: '',
    name:'',
    roles:[],
  },
  mutations: {
    setName(state, data) {
      state.name = data;
    }
  },
  plugins: [createPersistedState()]
})

export default store
